home *** CD-ROM | disk | FTP | other *** search
/ TPUG - Toronto PET Users Group / TPUG Users Group CD / TPUG Users Group CD.iso / AMIGA / (A)P / (A)P1.ADF / Polygon / polygon2.h < prev    next >
C/C++ Source or Header  |  1987-05-25  |  5KB  |  189 lines

  1. /* polygon.h -- definitions, etc with a little help from Lattice et al */
  2. /* gadgets courtesy of John Draper -- thanks */
  3.  
  4. #include "exec/types.h"
  5. #include "exec/nodes.h"
  6. #include "exec/lists.h"
  7. #include "exec/ports.h"
  8. #include "exec/devices.h"
  9. #include "devices/keymap.h"
  10. #include "graphics/regions.h"
  11. #include "graphics/copper.h"
  12. #include "graphics/gels.h"
  13. #include "graphics/gfxbase.h"
  14. #include "graphics/gfx.h"
  15. #include "graphics/sprite.h"
  16. #include "graphics/clip.h"
  17. #include "graphics/view.h"
  18. #include "graphics/rastport.h"
  19. #include "graphics/layers.h"
  20. #include "libraries/dos.h"
  21. #include "lattice/stdio.h"
  22. #include "lattice/math.h"
  23. #include "intuition/intuition.h"
  24. #include "hardware/dmabits.h"
  25. #include "hardware/custom.h"
  26. #include "hardware/blit.h"
  27. #include "graphics/text.h"
  28. #include "devices/timer.h"
  29. struct DateStamp now;
  30. long holdtime;
  31. static struct timerequest Time_Req;
  32. static struct MsgPort *Timer_Port = NULL, *CreatePort();
  33. #define NL 0
  34. long GfxBase = 0;   /* Base of graphics library */
  35. long IntuitionBase = 0;      /* Base of Intuition library */
  36. struct Window *OpenWindow();
  37. struct IntuiMessage *message;
  38. struct InputEvent *Intuition();
  39. struct Screen *OpenScreen();
  40. struct TextAttr TestFont = {
  41.    "topaz.font",TOPAZ_SIXTY,FS_NORMAL,FPF_ROMFONT, /* Define text font for screen */
  42.    };
  43. USHORT class;   /* Intu event class */
  44. USHORT code;   /* Intu event code */
  45. struct Window *w;      /* Lots of pointers for lots of things */
  46. struct RastPort *rp;
  47. struct ViewPort *vp;
  48. struct Screen *screen;
  49. #define  height 14
  50. struct SpriteImage {
  51. UWORD posctl[2];
  52. UWORD sprdata[2][height];
  53. UWORD reserved[2];
  54. };
  55.  
  56. /********************Sprite-Pointer-Defines*********************/
  57.  
  58. struct SpriteImage PointImage = {
  59.    100,100,
  60.    0x0000, 0x3ffe,
  61.    0x0000, 0x3ffe,
  62.    0x0080, 0x3ffe,
  63.    0x0080, 0x1ffc,
  64.    0x0080, 0x1ffc,
  65.    0x0080, 0x0ff8,
  66.    0x0080, 0x0ff8,
  67.    0x0000, 0x07f0,
  68.    0x0080, 0x07f0,
  69.    0x0080, 0x07f0,
  70.    0x0000, 0x03e0,
  71.    0x0000, 0x03e0,
  72.    0x0000, 0x01c0,
  73.    0x0000, 0x0080,
  74.    NULL,NULL
  75. };
  76.  
  77. int MathBase;
  78. int MathTransBase;
  79. union kludge1
  80. {
  81.    FLOAT num1;
  82.    int i1;
  83. } k1;
  84. union kludge2
  85. {
  86.    FLOAT num2;
  87.    int i2;
  88. } k2;
  89. union kludge3
  90. {
  91.    FLOAT num3;
  92.    int i3;
  93. } k3;
  94. union kludge4
  95. {
  96.    FLOAT num4;
  97.    int i4;
  98. } k4;
  99. /************************ Screen Defines ***********************************/
  100.  
  101. struct NewScreen ns = {
  102.    0,0,         /* start pos.*/
  103.    320,200,5,      /* width height depth (5 bit planes) */
  104.    0,2,         /* detail pen, block pen */
  105.    0,       /* viewing mode (normal 320x200) */
  106.    CUSTOMSCREEN,      /* screen type */
  107.    &TestFont,      /* font */
  108.    NULL,      /* screen title */
  109.    NULL,
  110.    NULL,      /* gadget pointer */
  111.    };
  112.  
  113. /************************ Window Defines ***********************************/
  114.  
  115. struct NewWindow nw = {
  116.       0,0,         /* Starting corner */
  117.       320,200,      /* Width, height */
  118.       0,3,         /* detail, block pens */
  119.       CLOSEWINDOW | MENUPICK
  120.       | REFRESHWINDOW | MOUSEBUTTONS | MOUSEMOVE,         /* IDCMP flags */
  121.       SMART_REFRESH | ACTIVATE | BORDERLESS | WINDOWCLOSE
  122.       | REPORTMOUSE | GIMMEZEROZERO,
  123.                /* Window flags */
  124.       NULL,         /* Pointer to first gadget */
  125.       NULL,         /* Pointer to checkmark */
  126.       "          Polygon",      /* title */
  127.       NULL,         /* screen pointer */
  128.       NULL,         /* bitmap pointer */
  129.       0,0,0,0,      /* sizing limits */
  130.       CUSTOMSCREEN      /* type of screen */
  131.       };
  132.  
  133. /************************ Set-Up routine ***********************************
  134. *   This function opens the Intuition and Graphics libraries, then     *
  135. *       opens up our custom screen and window, defining screen colors,     *
  136. *   size, etc...                        *
  137. ***************************************************************************/
  138. initwind()
  139. {
  140.    register int dd,l;
  141.  
  142.    GfxBase = OpenLibrary("graphics.library",0); /* Get graphics driver */
  143.    if(GfxBase == NULL)
  144.    {
  145.       printf("Can't open graphics library...\n");
  146.       exit();
  147.    }
  148.    if((MathBase=OpenLibrary("mathffp.library",0)) < 1) {
  149.       printf("n\n*** ERROR *** Can't open mathffp.library");
  150.       exit();
  151.    }
  152.    if((MathTransBase=OpenLibrary("mathtrans.library",0)) < 1) {
  153.       printf("n\n*** ERROR *** Can't open mathtrans.library");
  154.       exit();
  155.    }
  156.    IntuitionBase = OpenLibrary("intuition.library",0); /*Get Intuition*/  
  157.    if(IntuitionBase == NULL)
  158.    {
  159.       printf("Can't open intuition library...\n");
  160.       exit();
  161.    }
  162.    screen = OpenScreen(&ns); /* Open our new screen */
  163.    if(screen == NULL)
  164.    {
  165.       exit(0);
  166.    }
  167.    Timer_Port = CreatePort("Timer Port",0);
  168.    if(Timer_Port == NULL)
  169.    {
  170.       printf("Can't create timer port...\n");
  171.       exit();
  172.    }
  173.    if (OpenDevice(TIMERNAME, UNIT_VBLANK, (char *) &Time_Req,0) != NULL)
  174.    {
  175.       printf("Can't open timer device");
  176.       exit();
  177.    }
  178.    DateStamp(&now);
  179.    holdtime = now.ds_Minute + now.ds_Tick;
  180.    nw.Screen = screen;
  181.    w = OpenWindow(&nw);      /* Open our new window */
  182.    rp = w->RPort;         /* Get the raster port pointer */
  183.    vp = &screen->ViewPort;   /* Get the view port pointer */
  184.    SetDrMd(rp,JAM1);
  185.    for (l=0;l<=holdtime;l++)    /* randomize random functions */
  186.       dd=RangeRand(15);
  187. }
  188.  
  189.